﻿/***************************************************************************
 *  Project: WinFormsSample
 *  File:    WebForm.cs
 *  Version: 1.6.5.0
 *
 *  Copyright ©2012 Perikles C. Stephanidis; All rights reserved.
 *  This code is provided "AS IS" without warranty of any kind.
 *__________________________________________________________________________
 *
 *  Notes:
 *
 *  Demonstrates rendering an Awesomium WebView to a Windows Forms UI.
 *  In this sample, we simply render on the Form itself. In a real-life
 *  scenario, this should be a custom user control.
 *  
 *  This sample is available for both Awesomium.NET (.NET 4.0) as well
 *  as for Awesomium.Mono (.NET 2.0 & 4.0), for use with Mono on 
 *  all platforms.
 *   
 ***************************************************************************/

#region Using
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

#if USING_MONO
using Awesomium.Mono;
using Awesomium.Mono.Forms;
#else
using Awesomium.Core;
using Awesomium.Windows.Forms;
using Vlc.DotNet.Core.Medias;
#endif
#endregion

namespace WinFormsSample
{
    public partial class MainForm : Form
    {
        
        #region Ctors
        public MainForm()
        {
            // Notice that Control.DoubleBuffered has been set to true
            // in the designer, to prevent flickering.

            InitializeComponent();
            this.DownlodMonitor.ClosePanelForm += new EventHandler(ApplicationForm_Click);
            
        }

      
        #endregion

        private void webControl1_Paint(object sender, PaintEventArgs e)
        {
            

            System.Collections.Specialized.NameValueCollection myCol =
                new System.Collections.Specialized.NameValueCollection();
            myCol.Add("Referer", "http://localhost:8877/Nessgina/");
            webControl1.SetHeaderDefinition("MyHeader", myCol);
            webControl1.AddHeaderRewriteRule("http://*", "MyHeader");
            webControl1.Paint -= webControl1_Paint;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            webControl1_Paint(null,null);
        }

        private void webControl1_Download(object sender, UrlEventArgs e)
        {
            MessageBox.Show(e.Url);
            webControl1_Paint(null, null);
         

        }

        private void ColosBtn_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void MinimisideBtn_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void ApplicationForm_Click(object sender, EventArgs e)
        {
            this.webControl1.Visible = true;
            this.DownlodMonitor.Visible = false;

            this.DownloadForm.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(127)))), ((int)(((byte)(127))))); ;
            this.ApplicationForm.ForeColor = System.Drawing.Color.Silver;
            
        }

        private void DownloadForm_Click(object sender, EventArgs e)
        {
            this.webControl1.Visible = false;
            this.DownlodMonitor.Visible = true;
            this.DownlodMonitor.AddVideoToDownload("http://localhost:8877/data/films/American%20Pie%20Reunion.mkv");
            //this.Player.vlcControl.Pause();
            //this.Player.PlayUrl("http://localhost:8877/data/films/American%20Pie%20Reunion.mkv");

            Color a = this.ApplicationForm.ForeColor;
            this.DownloadForm.ForeColor = System.Drawing.Color.Silver;
            this.ApplicationForm.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(127)))), ((int)(((byte)(127)))));
            
            
        }
        
      

    }
}